<template>
<form>
  <div class="segment">
    <h1>Sign up</h1>
  </div>
  <label>
    <input type="text" placeholder="账户名" v-model="this.user.username" />
  </label>
  <label>
    <input type="password" placeholder="电话号码" v-model="this.user.phone" />
  </label>
  <label>
    <input type="password" placeholder="密码" v-model="this.user.password" />
  </label>
  <button class="red" type="button" @click="register()"><i class="icon ion-md-lock"></i> 注册</button>


</form>    
</template>

<script>
import { defineComponent } from 'vue';
import {doPost} from "../http/HttpRequest.js";

export default defineComponent({
    data(){
        return{
            //定义对象form
       user : {
        username: "",
        password: "",
        phone: "",
      }
        }
    },

    methods: {
        register(){
        doPost("/api/v1/register/check",JSON.stringify(this.user)).then(resp=>{
        // eslint-disable-next-line
        if(resp.data.code==="0000"){

        //重定向到另一个工程的页面  
        window.location.href = '/';
        } else {  
        // 登录失败，显示错误消息或其他逻辑  
        console.error('注册失败', resp.data.message); // 假设服务器返回了错误信息  
      }  
      })
        }
    }
})
</script>

<style lang="scss">
@import '/src/CSS/relievo.scss';
</style>